<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  MY_xml_helper.php
//  ColdXin_CI
//  
//  Created by Will_Lee on 2011-04-12.
//  Copyright 2011 lishuzu. All rights reserved.
// 

function xmlmessage($data){
	 $xmlmessage = '';
	foreach ($data as $key => $value) {
		if(is_array($value)){
			$xmlmessage .= "<DATA>";
			foreach ($value as $subk => $subv) {
				$xmlmessage .= "<".strtoupper($subk)."><![CDATA[".$subv."]]>"."</".strtoupper($subk).">";			
			}
			$xmlmessage .= "</DATA>";
		}else {
			$xmlmessage .= "<DATA>";
			$xmlmessage .= "<".strtoupper($key)."><![CDATA[".$value."]]>"."</".strtoupper($key).">";			
			$xmlmessage .= "</DATA>";
		}

	}
	return $xmlmessage;
}

function xmlecho($text) {
	obclean();
	@header("Expires: -1");
	@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
	@header("Pragma: no-cache");
	header("Content-type: application/xml");
	echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
	echo "<DATAS>\n";
	echo $text;
	echo "</DATAS>";
	exit;
}
?>